#define _CRT_SECURE_NO_WARNINGS

#include"game.h"
void menu()
{
 printf("***********************\n");
 printf("***********************\n");
 printf("******1  开始游戏******\n");
 printf("******0  退出游戏******\n");
 printf("***********************\n");
 printf("***********************\n");
}
void game()//创建游戏函数
{
 int ret = 0;
 char arr[ROW][COL] = {0};
 INITarr( arr,ROW,COL);//初始化棋盘
 Displayarr(arr, ROW, COL);//创建表格样子
 while (1)
 {
  //玩家下棋
  playmove(arr, ROW, COL);
  Displayarr(arr, ROW, COL);
  //判断输赢
  ret = Orwin(arr, ROW, COL);
  if (ret != 'C') {
   break;
  }

  //电脑下棋
  compertermove(arr, ROW, COL);
  Displayarr(arr, ROW, COL);
  //判断输赢
  ret = Orwin(arr, ROW, COL);
  if (ret != 'C') {
   break;
  }

 }
 if (ret == '*') {
  printf("玩家赢\n");
 }
 else if (ret == '#')
 {
  printf("电脑赢\n");
 }
 else
 {
  printf("平局\n");
 }
}

 

int main()
{
 int i = 0;
 do
 {
  menu();
  scanf("%d", &i);
  switch (i)
  {
  case 1:
  
   game();
   break;
  case 0:
   printf("退出游戏\n");
   break;
  default:
   printf("选择错误，请重新选择\n");
  }
 } while (i);

 return 0;
}